@ECHO OFF
ECHO any comments suggestions are welcome at : 
ECHO http://ysgitdiary.blogspot.com/search/label/textpad
ECHO This batch file copies some the needed settings of textpad
ECHO it depends on a simple GetNiceTime_on_%computername%.cmd 
ECHO batch file producing the %_NICETIME% variable in YYYYMMDD_hhmmss 
ECHO format
ECHO Tested on Win7 64 -bit TextPad v.5.4.2 
ECHO you should call this batch file from its current directorry

:: GET A YYYYMMDD_hhmmss TIMESTAMP
call GetNiceTime_on_%computername%.cmd

SET _RegFileWithSettings=TextPadSettings_Helios_on_%COMPUTERNAME%_%NiceTime%.reg
SET _RunLog=%0.run.log
SET _ErrorLog=%0.error.log
SET _TextPadSynFilesDirOnWin64=%ProgramFiles(x86)%\TextPad 5\system
SET _PortableSynFilesDir=%CD%\system
SET _RegistryKey=HKEY_CURRENT_USER\Software\Helios\TextPad 5
SET _RegistryFilesDir=%CD%\reg
SET _RegistryFileWithSettings=%_RegistryFilesDir%\TextPadSettings_HeliosKey_on_%computername%_%NiceTime%.reg

ECHO START REGISTRY SETTINGS EXPORT AT %_NiceTime%
ECHO RUN LOG : START REGISTRY SETTINGS EXPORT AT %_NiceTime%  >%_RunLog%
ECHO ERROR LOG START REGISTRY SETTINGS EXPORT AT %_NiceTime%  >%_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%

ECHO create a directory called sysm in the current directory 
ECHO create a directory called sysm in the current directory 1>>%_RunLog% 2>> %_ErrorLog% 
ECHO.1>>%_RunLog% 2>> %_ErrorLog%

ECHO now copy alls the files from the %Program Files(x86)%\TextPad 5\system\ 
ECHO now copy alls the files from the %Program Files(x86)%\TextPad 5\system\ 1>>%_RunLog% 2>> %_ErrorLog%

ECHO IF NOT EXIST %_PortableSynFilesDir% MKDIR %_PortableSynFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
IF NOT EXIST %_PortableSynFilesDir% MKDIR %_PortableSynFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%

ECHO COPY EACH syn files 
for /f "tokens=*" %%i in (' dir "%_TextPadSynFilesDirOnWin64%\*.syn" /s /b') do copy /y "%%i" "%_PortableSynFilesDir%" 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%

:: CREATE THE _RegistryFilesDir if it does not exist 
ECHO IF NOT EXIST %_RegistryFilesDir% MKDIR %_RegistryFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
IF NOT EXIST %_RegistryFilesDir% MKDIR %_RegistryFilesDir% 1>>%_RunLog% 2>> %_ErrorLog%
ECHO.1>>%_RunLog% 2>> %_ErrorLog%

:: NOW PERFORM THE ACTUAL EXPORT OF THE CURRENT SETTINGS
ECHO REG EXPORT "%_RegistryKey%" "%_RegistryFileWithSettings%" 1>>%_RunLog% 2>> %_ErrorLog%
REG EXPORT "%_RegistryKey%" "%_RegistryFileWithSettings%"

ECHO DONE NOW OPEN THE LOG FILES TO SEE THE RESULTS  :
FOR /F %%i in ('dir "%CD%\*.log" /s /b') do cmd /c start /max textpad "%%i"

:: NOW OPEN TO VIEW THE REGISTRY FILE AS WELL
CMD /C START /MAX textpad %_RegistryFileWithSettings%

:: HINT: you could execute any dos file including this one by creating a new external tool
:: Command: cmd.exe , Parameters: CMD /C $FileName , Check Prompt for parameters 
:: Check Save all documents first , Check Capture output , Check Suppress output untill completed
:: TODO: Add check for 32-bit or 64-bit and copy syn files for that 
:: TODO: Create an NSIS script packing all this into single setup.exe
